﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="QuestionList.aspx.vb" Inherits="FishTank.QuestionList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <link rel="alternate" type="application/rss+xml" href="/Pages/QuestionRSS.aspx" title="RSS feed" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="rss">
        <a href="/Pages/QuestionRSS.aspx"><asp:Image ID="rssImg" runat="server" ImageUrl="~/Images/rss.png" /></a>
    </div>

    <h1>Questions and Answers</h1>

    <div class="search">
        Search by 
        <asp:DropDownList ID="SearchType" runat="server">
            <asp:ListItem Value="Title">Title</asp:ListItem>
            <asp:ListItem Value="MemberFullName">Member</asp:ListItem>
            <asp:ListItem Value="Tag">Tag</asp:ListItem>
        </asp:DropDownList>
        <asp:TextBox ID="SearchBox" runat="server" AutoPostBack="True"></asp:TextBox>
        <asp:Button ID="SearchButton" runat="server" Text="Go" />
        <asp:Button ID="ResetButton" runat="server" Text="Reset" />
    </div>
    
    <p>
    <asp:GridView ID="ListGrid" runat="server" AutoGenerateColumns="False"
        AllowSorting="True" Width="100%"
        CssClass="gridView">

        <AlternatingRowStyle CssClass="gridAltRowView" />

        <EmptyDataTemplate>
        <p>Your search did not match any questions.</p>
        </EmptyDataTemplate>

        <Columns>
             <asp:TemplateField HeaderText="Member" SortExpression="MemberFullName">
                <ItemTemplate>  
                    <a href="/Pages/MemberDetail.aspx?UserName=<%# Eval("MemberUserName") %>">
                        <asp:Image ID="ProfilePhoto" runat="server"
                                   ImageUrl='<%# GetPhotoPath(Eval("MemberPhoto")) %>' AlternateText="<%# Bind('MemberUserName') %>"/>
                    </a>
                    <p><asp:Label ID="Label1" runat="server" Text="<%# Bind('MemberFullName') %>"></asp:Label></p>
                </ItemTemplate>
                <ItemStyle Width="96" Height="64" CssClass="centered" />
            </asp:TemplateField>
            <asp:HyperLinkField DataNavigateUrlFields="ID" 
                DataNavigateUrlFormatString="/Pages/QuestionDetail.aspx?ID={0}" DataTextField="Title" 
                HeaderText="Question Title" SortExpression="Title" />
            <asp:BoundField DataField="TotalAnswers" HeaderText="Answers" 
                SortExpression="TotalAnswers" ItemStyle-CssClass="centered" />
            <asp:BoundField DataField="CreatedDateTime" HeaderText="Created Date" 
                dataformatstring="{0:MMMM d, yyyy}" ItemStyle-CssClass="centered"
                SortExpression="CreatedDateTime" />
            <asp:TemplateField HeaderText="Tags">
                <ItemTemplate>   
                    <asp:Repeater ID="TagRepeater" runat="server" DataSource='<%# GetQuestionTags(Eval("ID")) %>'>
                        <SeparatorTemplate>,</SeparatorTemplate>
                        <ItemTemplate>
                            <asp:LinkButton ID="TagLinkButton" runat="server" Text='<%# Bind("Title") %>'
                                            OnClick="SearchLinkButton_Click" CommandArgument='<%# Bind("Title") %>'/>
                        </ItemTemplate>
                    </asp:Repeater>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    </p>

    <p class="submitButton">
        <asp:Button ID="CreateButton" runat="server" CommandName="Create" Text="Ask a question" />
    </p>

    <div class="tagCloud">
        <asp:Repeater ID="TagCloudRepeater" runat="server">
            <ItemTemplate>
                <asp:LinkButton ID="TagLinkButton" runat="server"
                                Text='<%# Bind("Tag") %>'
                                Font-Size='<%# GetTagFontUnit(Eval("Tag"), Eval("Weight")) %>'
                                OnClick="SearchLinkButton_Click"
                                CommandArgument='<%# Bind("Tag") %>'/>
            </ItemTemplate>
           
        </asp:Repeater>
    </div>
</asp:Content>
